
//建立一个简单的迭代类(yield)

class MyList {
	
	constructor(list){
		this.list = list;
		this[Symbol.iterator] = function*(){//这里
			let current = 0;
			let that = this;
			while(current < that.list.length){
				yield that.list[current++];
			}
		}
	}
}

let mylist = new MyList([100, 200, 300, 400, 500]);
for(let val of mylist){
	console.log(val);
}
//100
//200
//300
//400
//500
